﻿using Rechargeable.Products.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;

namespace Rechargeable.Products
{
    public class ProductAppService : CrudAppService<
        Product, ProductDto, Guid, PagedAndSortedResultRequestDto,
        CreateUpdateProductDto, CreateUpdateProductDto>,
        IProductAppService
    {
        public ProductAppService(IRepository<Product, Guid> repository) : base(repository)
        { }

        protected override async Task<IQueryable<Product>> CreateFilteredQueryAsync(PagedAndSortedResultRequestDto input)
        {
            var query = await base.CreateFilteredQueryAsync(input);
            return query.Where(q => q.CreatorId == CurrentUser.Id);
        }
    }
}
